<template>
  <div class="video-data">
    <div class="video-list">
      <div class="video-item" v-for="(item,index) in videoData" :key="index" @click="openVideo(index)">
        <img v-lazy="item.img"/>
        <span>{{item.title}}</span>
      </div>
    </div>
    <div class="load-more" @click="loadMore">
      <p v-if="isMore">{{isLoadMore?'加载中...':'加载更多'}}</p>
      <p v-if="!isMore">暂无更多数据</p>
    </div>
  </div>
</template>

<script>
  export default {
    name: "VideoList",
    data() {
      return {
        videoData: window.videoData,
        page:1,
        isLoadMore:false,
        isMore:true
      }
    },
    mounted(){
      //获取数据
      // this.getData();
    },
    methods: {
      openVideo(index) {
        window.open(this.videoData[index].src);
      },
      loadMore() {

        if(!this.isMore){
          return;
        }
        this.page++;
        this.isLoadMore=true;
        this.$get("/getVideoList",{type:0,page:this.page}).then((res)=>{
          if(res.code==1){
            this.isLoadMore = false;
            this.isMore=false;
            alert("暂无更多数据");
            return;
          }
          res.data.forEach((item)=>{
            this.videoData.push(item);
          })

          this.isLoadMore = false;
          
        });
      }
    }
  }
</script>

<style lang="scss" scoped>
  .video-data {
    margin-bottom: .16rem;
    .video-list {
      margin-bottom: .01rem;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      padding-left: 12px;
      flex-wrap: wrap;
      padding-top: .16rem;
      .video-item {
        flex: 0 0 46.6%;
        width: 50%;
        height: 100%;
        border-radius: .01rem;
        padding-right: .12rem;
        padding-bottom: .12rem;
        img {
          border-radius: .1rem;
          width: 100%;
          height: 1rem;
        }
        span {
          font-size: .1rem;
          line-height: .008rem;
        }
      }
    }
    .load-more {
      text-align: center;
      padding: .10rem;
      background: #ffffff;
      font-size: .13rem;
    }
  }
</style>
